home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume4 / s5nap < prev    next >
Encoding:
Internet Message Format  |  1989-02-03  |  3.4 KB

  1. Path: xanth!nic.MR.NET!hal!ncoast!allbery
  2. From: zeeff@b-tech.ann-arbor.mi.us.UUCP (Jon Zeeff)
  3. Newsgroups: comp.sources.misc
  4. Subject: v04i128: Simple nap() for Sys V
  5. Message-ID: <4874@b-tech.ann-arbor.mi.us>
  6. Date: 22 Oct 88 01:17:42 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: zeeff@b-tech.ann-arbor.mi.us.UUCP (Jon Zeeff)
  9. Organization: Branch Technology, Ann Arbor, MI
  10. Lines: 131
  11. Approved: allbery@ncoast.UUCP
  12.  
  13. Posting-number: Volume 4, Issue 128
  14. Submitted-by: "Jon Zeeff" <zeeff@b-tech.ann-arbor.mi.us.UUCP>
  15. Archive-name: s5nap
  16.  
  17. The kernel has a method for < 1 sleeps - allow user process to do so also.
  18.  
  19. #! /bin/sh
  20. # This is a shell archive.  Remove anything before this line, then unpack
  21. # it by saving it into a file and typing "sh file".  To overwrite existing
  22. # files, type "sh file -c".  You can also feed this as standard input via
  23. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  24. # will see the following message at the end:
  25. #        "End of shell archive."
  26. # Contents:  ft.c nap.c test.c
  27. # Wrapped by zeeff@b-tech on Mon Oct 17 10:17:48 1988
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f ft.c -a "${1}" != "-c" ; then 
  30.   echo shar: Will not over-write existing file \"ft.c\"
  31. else
  32. echo shar: Extracting \"ft.c\" \(1082 characters\)
  33. sed "s/^X//" >ft.c <<'END_OF_ft.c'
  34. X
  35. X/*
  36. X   Written by Jon Zeeff umix!b-tech!zeeff
  37. X
  38. X   This "device driver" uses the kernel delay() call to allow calls
  39. X   to nap() from user processes.  Nap() is like sleep, but with finer
  40. X   resolution.
  41. X   Compile with cc -O  -c ft.c 
  42. X
  43. X   Written for a Sys V.3 system, but should work on others.
  44. X
  45. X   For Sys V.3:
  46. X   
  47. X   Make a new kernel according to the instructions and then:
  48. X   mknod /dev/ft c 28 0 
  49. X
  50. X   modules/ft/config:
  51. X       character(28)
  52. X       prefix = ft 
  53. X       functions = open, close, read
  54. X   
  55. X   Edit systems/system.std and add ft.
  56. X   Copy ft.o to modules/ft/config
  57. X
  58. X*/
  59. X
  60. X#include <sys/signal.h>
  61. X#include <sys/types.h>
  62. X#include <sys/sysmacros.h>
  63. X#include <sys/param.h>
  64. X#include <sys/systm.h>
  65. X#include <sys/buf.h>
  66. X#include <sys/iobuf.h>
  67. X#include <sys/conf.h>
  68. X#include <sys/dir.h>
  69. X#include <sys/user.h>
  70. X#include <sys/utsname.h>
  71. X#include <sys/elog.h>
  72. X#include <sys/errno.h>
  73. X#include <sys/trap.h>
  74. X#include <sys/seg.h>
  75. X#include <sys/map.h>
  76. X
  77. X/* use a raw device interface */
  78. X
  79. Xftopen() {}
  80. X
  81. Xftread(dev)
  82. Xint dev;
  83. X{
  84. Xdelay(u.u_count);
  85. Xu.u_count = 0;
  86. X}
  87. X
  88. Xftwrite() {}
  89. Xftclose() {}
  90. X
  91. END_OF_ft.c
  92. if test 1082 -ne `wc -c <ft.c`; then
  93.     echo shar: \"ft.c\" unpacked with wrong size!
  94. fi
  95. # end of overwriting check
  96. fi
  97. if test -f nap.c -a "${1}" != "-c" ; then 
  98.   echo shar: Will not over-write existing file \"nap.c\"
  99. else
  100. echo shar: Extracting \"nap.c\" \(115 characters\)
  101. sed "s/^X//" >nap.c <<'END_OF_nap.c'
  102. X
  103. Xnap(ticks)
  104. Xunsigned ticks;
  105. X{
  106. Xstatic int fd=0;
  107. X
  108. Xif (fd == 0) fd = open("/dev/ft",0);
  109. Xread(fd,(char *)0,ticks);
  110. X
  111. X}
  112. X
  113. END_OF_nap.c
  114. if test 115 -ne `wc -c <nap.c`; then
  115.     echo shar: \"nap.c\" unpacked with wrong size!
  116. fi
  117. # end of overwriting check
  118. fi
  119. if test -f test.c -a "${1}" != "-c" ; then 
  120.   echo shar: Will not over-write existing file \"test.c\"
  121. else
  122. echo shar: Extracting \"test.c\" \(26 characters\)
  123. sed "s/^X//" >test.c <<'END_OF_test.c'
  124. X
  125. Xmain()
  126. X{
  127. X
  128. Xnap(1000);
  129. X
  130. X}
  131. X
  132. END_OF_test.c
  133. if test 26 -ne `wc -c <test.c`; then
  134.     echo shar: \"test.c\" unpacked with wrong size!
  135. fi
  136. # end of overwriting check
  137. fi
  138. echo shar: End of shell archive.
  139. exit 0
  140. -- 
  141. Jon Zeeff                  Branch Technology,
  142. umix!b-tech!zeeff          zeeff@b-tech.ann-arbor.mi.us
  143.